package com.knight.hadoop.day10.preprocess;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;

/**
 * 预处理web日志的object
 * @author 
 *
 */
public class WebLogObject{
	
	private String requestIP;
	private String requestDate;
	private String requestMethod;
	private String requestURL;
	private String requestProtocol;
	private String responseCode;
	private String responseDataSize;
	private String requestSourcesURL;
	private String customerInfo;
	private boolean valid = true;//判断数据是否合法
	
	
	public WebLogObject() {
	}


	public void set(String requestIP, String requestDate, String requestMethod, String requestURL,
			String requestProtocol, String responseCode, String responseDataSize, String requestSourcesURL,
			String customerInfo, boolean valid) {
		this.requestIP = requestIP;
		this.requestDate = requestDate;
		this.requestMethod = requestMethod;
		this.requestURL = requestURL;
		this.requestProtocol = requestProtocol;
		this.responseCode = responseCode;
		this.responseDataSize = responseDataSize;
		this.requestSourcesURL = requestSourcesURL;
		this.customerInfo = customerInfo;
		this.valid = valid;
	}
	
	public void set(String requestIP, String requestDate, String requestMethod, String requestURL,
			String requestProtocol, String responseCode, String responseDataSize, String requestSourcesURL,
			String customerInfo) {
		this.requestIP = requestIP;
		this.requestDate = requestDate;
		this.requestMethod = requestMethod;
		this.requestURL = requestURL;
		this.requestProtocol = requestProtocol;
		this.responseCode = responseCode;
		this.responseDataSize = responseDataSize;
		this.requestSourcesURL = requestSourcesURL;
		this.customerInfo = customerInfo;
	}

	public String getRequestDate() {
		return requestDate;
	}

	public void setRequestDate(String requestDate) {
		this.requestDate = requestDate;
	}

	public String getRequestMethod() {
		return requestMethod;
	}

	public void setRequestMethod(String requestMethod) {
		this.requestMethod = requestMethod;
	}

	public String getRequestURL() {
		return requestURL;
	}

	public void setRequestURL(String requestURL) {
		this.requestURL = requestURL;
	}

	public String getResponseCode() {
		return responseCode;
	}

	public void setResponseCode(String responseCode) {
		this.responseCode = responseCode;
	}

	public String getResponseDataSize() {
		return responseDataSize;
	}

	public void setResponseDataSize(String responseDataSize) {
		this.responseDataSize = responseDataSize;
	}

	public String getRequestSourcesURL() {
		return requestSourcesURL;
	}

	public void setRequestSourcesURL(String requestSourcesURL) {
		this.requestSourcesURL = requestSourcesURL;
	}

	public String getCustomerInfo() {
		return customerInfo;
	}

	public void setCustomerInfo(String customerInfo) {
		this.customerInfo = customerInfo;
	}

	public String getRequestIP() {
		return requestIP;
	}

	public void setRequestIP(String requestIP) {
		this.requestIP = requestIP;
	}


	public String getRequestProtocol() {
		return requestProtocol;
	}


	public void setRequestProtocol(String requestProtocol) {
		this.requestProtocol = requestProtocol;
	}


	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(valid);
		sb.append("\001").append(requestIP);
		sb.append("\001").append(requestDate);
		sb.append("\001").append(requestMethod);
		sb.append("\001").append(requestURL);
		sb.append("\001").append(requestProtocol);
		sb.append("\001").append(responseCode);
		sb.append("\001").append(responseDataSize);
		sb.append("\001").append(requestSourcesURL);
		sb.append("\001").append(customerInfo);
		return sb.toString();
	}


	public boolean isValid() {
		return valid;
	}


	public void setValid(boolean valid) {
		this.valid = valid;
	}
	
}
